import { ItemData } from "./ItemData";
type int = number;
//class CopySkillInfo
    
    export  class CopySkillInfo
    {
        constructor()
        {
            
            this.materialDic = new Map<any, any> /* flash.utils.Dictionary */();
            return;
        }

        public set formula(arg1: Array<any>)
        {
            var loc1=null;
            var loc2=0;
            var loc3=0;
            this._formula = [];
            if (arg1 && arg1.length > 0) 
            {
                loc3 = 0;
                while (loc3 < arg1.length) 
                {
                    loc1 = (arg1[loc3] as string).split(",");
                    loc2 = parseInt(loc1[0]);
                    this.materialDic[loc2] = {"itemCode": loc2, "itemData": new ItemData(loc2), "amountNeed": parseInt(loc1[1]), "amountOwn": 0};
                    this._formula.push(this.materialDic[loc2]);
                    ++loc3;
                }
            }
            return;
        }

        public get formula(): Array<any>
        {
            return this._formula;
        }

        public get name(): string
        {
            var loc1=new ItemData(this.itemCode);
            return loc1.name;
        }

        public setMaterialOwn(arg1: int, arg2: int): void
        {
            this.materialDic[arg1]["amountOwn"] = arg2;
            return;
        }

        public getMaterialNeed(arg1: int): int
        {
            return this.materialDic[arg1] ? this.materialDic[arg1]["amountNeed"] : 0;
        }

        public isSameCombination(arg1: Array<any>): Boolean
        {
            var loc4=0;
            var loc5=0;
            var loc6=0;
            var loc7=undefined;
            var loc1=false;
            var loc2=new Map<any, any> /* flash.utils.Dictionary */();
            var loc3=[];
            loc5 = 0;
            while (loc5 < arg1.length) 
            {
                loc4 = arg1[loc5];
                if (loc2[loc4] && !(loc2[loc4] == 0)) 
                {
                    loc2[loc4] = loc2[loc4] + 1;
                }
                else 
                {
                    loc2[loc4] = 1;
                    loc3.push(loc2[loc4]);
                }
                ++loc5;
            }
            if (this._formula && loc3.length == this._formula.length) 
            {
                loc6 = 0;
                var loc8=0;
                var loc9=this.materialDic;
                for (loc7 in loc9) 
                {
                    if (loc2[loc7] != this.materialDic[loc7]["amountNeed"]) 
                    {
                        continue;
                    }
                    loc6 = loc6 + 1;
                }
                if (loc6 == this._formula.length) 
                {
                    loc1 = true;
                }
            }
            return loc1;
        }

        public /* var */copyCode: int;

        public /* var */itemCode: int;

        public /* var */pos: int;

        public /* var */materialDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_formula: Array<any>;
    }
